import { defineStore } from "pinia";
import { reactive, ref ,computed} from "vue";
import { getCurrentRolePermissionListApi } from "@/api/permission";
export default defineStore("permission", () => {
  let currentpermission = ref([]);
  let getCurrentRolePermission = (currentRoleid) => {
    getCurrentRolePermissionListApi({ type: 1, roleid: currentRoleid }).then(
      (res) => {
        // console.log(res);
        currentpermission.value = res.data.data;
      }
    );
  };
  let currentpermissionId = computed(()=>{
    return currentpermission.value.map(item=>item.id)
 })
  return { currentpermission, getCurrentRolePermission , currentpermissionId}
},
{
    persist: true,
  });
